<template>
	<view class="comment-container">
		<view class="comment-box">
			<view class="comment-count">
				好物评价（{{ commentInfo.total }}）
			</view>
			<view class="comment-add" @click="comment">
				<text>评价</text>+
			</view>
		</view>
		<view class="comment-list" v-if="commentInfo.records && commentInfo.records.length > 0">
			<view class="comment-item" v-for="comment in commentInfo.records" :key="comment.id">
				<view class="userinfo">
					<view class="userinfo-left">
						<view class="avatar">
							<image :src="$imageUrl + comment.avatar" mode=""></image>
						</view>
						<text class="username">{{ comment.nickName }}</text>
					</view>
					<view class="userinfo-right">
						<view class="publish-time">
							{{ comment.publishTime }}
						</view>
					</view>
				</view>
				<view class="comment-content">
					{{ comment.content }}
				</view>
			</view>
			<view class="see-all" @click="seeAllComments">
				查看全部&gt;
			</view>
		</view>
		<view class="content" v-else>
			暂无评价T_T
		</view>
	</view>
</template>

<script>
	export default {
		name: "my-comment-container",
		props: {
			commentInfo: {
				type: Object,
			},
		},
		data() {
			return {

			}
		},
		methods: {
			seeAllComments() {
				this.$emit('seeAllComments')
			},
			comment() {
				this.$emit('comment')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.comment-container {
		padding: 20rpx;

		.comment-box {
			display: flex;
			justify-content: space-between;
		}
	}

	.comment-box {
		color: #000;
		font-weight: bold;
		height: 30px;
		line-height: 60rpx;

		.comment-count {
			vertical-align: middle;
		}

		.comment-add {
			color: #d9d9d9;
			font-size: 20px;
			// height: 30px;
			// line-height: 30px;
			font-weight: normal;
			display: flex;
			align-items: center;
			vertical-align: middle;

			text {
				font-size: 12px;
				// vertical-align: middle;
			}
		}
	}

	.comment-list {
		.see-all {
			color: #d9d9d9;
			font-size: 12px;
			text-align: center;
			letter-spacing: 4rpx;
		}
	}

	.comment-item {
		margin: 20rpx 0;

		.userinfo {
			display: flex;
			margin-bottom: 20rpx;
			justify-content: space-between;

			.userinfo-left {
				display: flex;
			}

			.avatar {
				width: 50rpx;
				height: 50rpx;
				overflow: hidden;
				border-radius: 50%;
				margin-right: 10rpx;

				image {
					width: 100%;
					height: 100%;
				}
			}

			.username {
				display: flex;
				font-size: 14px;
				align-items: center;
			}

			.publish-time {
				font-size: 12px;
			}
		}
	}

	.comment-content {
		font-size: 10px;

		&.hide {
			overflow: hidden; //多出的隐藏
			text-overflow: ellipsis; //多出部分用...代替
			display: -webkit-box; //定义为盒子模型显示
			-webkit-line-clamp: 2; //用来限制在一个块元素显示的文本的行数
			-webkit-box-orient: vertical; //从上到下垂直排列子元素（设置伸缩盒子的子元素排列方式）
		}
	}

	.content {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		box-sizing: border-box;
		padding: 20px;
	}
</style>
